<%-- 
    Document   : RegistrarEventoReserva
    Created on : 23/07/2008, 11:03:01 AM
    Author     : Alejandro
--%>

<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="com.akcess.vo.*" %>
<%@ page language="java" import="com.akcess.impl.*" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page language="java" import="manejadores.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <!--  Version: Multiflex-3.12 / Overview                    --><!--  Date:    January 20, 2008                             --><!--  Design:  www.1234.info                                --><!--  License: Fully open source without restrictions.      --><!--           Please keep footer credits with the words    --><!--           "Design by 1234.info" Thank you!             -->
    <script language="JavaScript">	
        <!--            
        function nuevoAjax(){
            var xmlhttp=false;
            try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
        
            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
            }
            return xmlhttp;
        } 
        function cargarContenido(){
            var cadena,t1,contenedor;
            contenedor = document.getElementById('ListaReservas');
            t1 = document.getElementById('TipoReserva').value;
            ajax=nuevoAjax();
            ajax.open("GET", "GestionarReservas?hacer=ListarReservas&id="+t1,true);
            ajax.onreadystatechange=function() {
                if (ajax.readyState==4) {
                    cadena=ajax.responseText                        
                    contenedor.innerHTML = cadena
                }
            }
            ajax.send(null)
        } 
        
        //-->
    </script>
    
    
    <base href="<%=basePath%>">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_setup.css">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_text.css">
    <link rel="icon" type="image/x-icon" href="./img/favicon.ico">
    <title>SRR - Sistema de Reserva de Recursos</title><!-- Global IE fix to avoid layout crash when single word size wider than column width --><!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
    <link href="./css/highlighter.css" type="text/css" rel="stylesheet">
    <link href="./css/highlighter_002.css" type="text/css" rel="stylesheet">
</head>
<body>
<!-- Main Page Container -->
<div class="page-container">
    
    <!-- For alternative headers START PASTE here -->

 <jsp:include page="../Header.jsp"/>
        
        <!-- For alternative headers END PASTE here -->

    <!-- B. MAIN -->
    <div class="main">
        
        <jsp:include page="../barraOperaciones.jsp"/>  
        
        <!-- B.2 MAIN CONTENT -->
        <div class="main-content">  
            <!-- Pagetitle -->
                   <%
            out.println("<h1 class=\"pagetitle\"> Reserva a nombre de : " + request.getParameter("NombreSolicitante") + "</h1>");
            out.println("<h1> Recurso : " + request.getParameter("NombreRecurso") + "</h1>");
            Connection cone;
            cone = (Connection) session.getAttribute("conexion");
            int idReserva = Integer.parseInt(request.getParameter("id"));
            ManejadorReservas manejador = new ManejadorReservas(cone);
            ManejadorRecursosHumanos manejadorRH = new ManejadorRecursosHumanos(cone);
            Evento[] eventosReserva = manejador.ObtenerEventos(idReserva);
            RecursoHumanoCompleto rrhh =null;

            out.println("<table border=\"0\">");
            out.println("<tbody>");
            out.println("<tr>");
            out.println("<th class=\"top\"><center>Evento</center></th>");
            out.println("<th class=\"top\"><center>Personal</center></th>");
            out.println("<th class=\"top\"><center>Fecha</center></th>");
            out.println("</tr>");
            if (eventosReserva != null && eventosReserva.length > 0) {
                for (int i = 0; i < eventosReserva.length; i++) {
                    out.println("<tr>");
                    out.println("<td>" + eventosReserva[i].getNombre() + "</td>");
                    if (eventosReserva[i].getId_enviador() != 0) {
                        rrhh = manejadorRH.ObtenerRecursoHumano((int)eventosReserva[i].getId_enviador());
                        out.println("<td>"+ rrhh.getNombre()+" "+ rrhh.getApellido() +"</center></td>");
                    } else {
                        out.println("<td>Ninguno</td>");
                    }
                    out.println("<td>" + eventosReserva[i].getFecha().toString() + "</td>");
                    out.println("</tr>");

                }
            }
            out.println("</tbody>");
            out.println("</table>");
                                %>
            </tbody>
            </table>          
            <div id="ListaReservas">
                <%
            String error = (String) request.getAttribute("Error");
            if (error != null) {
                out.println("<br><p><FONT FACE=\"arial\" SIZE=1 COLOR=red>" + error + "</FONT></p>");
            }

            out.println("<form name=\"crear\" action=\"GestionarReservas?hacer=opRegistrarEvento&id=" + idReserva + "&NombreSolicitante=" + request.getParameter("NombreSolicitante") + "&NombreRecurso=" + request.getParameter("NombreRecurso") + "\" method=\"post\">");
            %>
            </div>
            
            <table border="1">
                <tbody>
                    <tr>
                        <th class="top"><center>Personal</center></th>
                        <th class="top"><center>Evento</center></th>
                    </tr>
                    <tr>                                  
                        <%
            ManejadorRecursosHumanos manejadorHumano = new ManejadorRecursosHumanos(cone);
            RecursoHumanoCompleto[] humanos = manejadorHumano.ListarRecursosHumanos();

            //Select para seleccionar el encargado.
            out.println("<td><center><select name=\"Personal\">");
            out.println("<option value=\"null\">[Seleccione Personal]</option>");
            for (int j = 0; j < humanos.length; j++) {
                if (!humanos[j].getBorrado() && humanos[j].getDisponible()) {
                    out.println("<option value=" + humanos[j].getId_recurso() + "> " + humanos[j].getNombre() + " " + humanos[j].getApellido());
                }
            }
            out.println("</select></center></td>");

            //Select para seleccionar el evento. 
            ManejadorEventos manejadorEvento = new ManejadorEventos(cone);
            Evento[] eventos = manejadorEvento.ObtenerEventos();
            out.println("<td><center><select name=\"Evento\">");
            out.println("<option value=\"\">[Seleccione Evento]</option>");
            for (int i = 0; i < eventos.length; i++) {
                out.println("<option value=" + eventos[i].getId_evento() + "> " + eventos[i].getNombre());
            }
            out.println("</select></center></td>");

                        %>                                                                  
                    </tr>
                    <tr>
                        <td colspan="2"><center><input type="submit" name="btnGuardar" value="Registrar"></center></td>
                    </tr> 
                </tbody>    
            </table>
            </form>
            
            
            <!-- B.3 SUBCONTENT -->
        </div>
    </div>
    <!-- C. FOOTER AREA -->   
                <%@include file="../footer.jsp"%> 
</div>
</body>
</html>
